package de.uni.muenster.idw2.data;

import android.os.Parcel;
import android.os.Parcelable;

public class Connection implements Parcelable{


	private Room room1;
	private Room room2;
	private Position position1;
	private Position position2;
	private int id1;
	private int id2;
	
	public Connection(Parcel source){
		room1 = source.readParcelable(Room.class.getClassLoader());
		room2 = source.readParcelable(Room.class.getClassLoader());
		
		position1 = source.readParcelable(Position.class.getClassLoader());
		position2 = source.readParcelable(Position.class.getClassLoader());
		
		id1 = source.readInt();
		id2 = source.readInt();
	}
	
	public Connection(Room room1, Room room2, int id1, Position position1,
			Position position2, int id2) {
		super();
		this.room1 = room1;
		this.room2 = room2;
		this.position1 = position1;
		this.position2 = position2;
		this.id1 = id1;
		this.id2 = id2;
	}
	
	public Connection(Room room1, Position position1, int id1) {
		super();
		this.room1 = room1;
		this.position1 = position1;
		this.id1 = id1;

	}
	
	public Connection (Connection c1 , Connection c2){
		this.room1 = c1.getRoom1();
		this.room2 = c2.getRoom1();
		
		this.position1 = c1.getPosition1();
		this.position2 = c2.getPosition1();
		
		this.id1 = c1.id1;
		this.id2 = c2.id1;
	}

	public Room getRoom1() {
		return room1;
	}

	public void setRoom1(Room room1) {
		this.room1 = room1;
	}

	public Room getRoom2() {
		return room2;
	}

	public void setRoom2(Room room2) {
		this.room2 = room2;
	}

	public Position getPosition1() {
		return position1;
	}

	public void setPosition1(Position position1) {
		this.position1 = position1;
	}

	public Position getPosition2() {
		return position2;
	}

	public void setPosition2(Position position2) {
		this.position2 = position2;
	}

	public int getId1() {
		return id1;
	}

	public void setId1(int id1) {
		this.id1 = id1;
	}

	public int getId2() {
		return id2;
	}

	public void setId2(int id2) {
		this.id2 = id2;
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeParcelable(room1, flags);
		dest.writeParcelable(room2, flags);
		
		dest.writeParcelable(position1, flags);
		dest.writeParcelable(position2, flags);
		
		dest.writeInt(id1);
		dest.writeInt(id2);
	}
	
	public static final Parcelable.Creator CREATOR = new Creator() {

		@Override
		public Connection createFromParcel(Parcel source) {
			return new Connection(source);
		}

		@Override
		public Connection[] newArray(int size) {
			return new Connection[size];
		}
	};
	
}
